from OCC.Core.BRep import BRep_Tool
from OCC.Core.TopAbs import TopAbs_EDGE
from OCC.Core.TopExp import TopExp_Explorer, topexp_FirstVertex, topexp_LastVertex
from OCC.Display.SimpleGui import init_display
from OCC.Extend.DataExchange import read_stl_file
from OCC.Extend.ShapeFactory import make_wire

shapes = read_stl_file('./1.stl')

print(shapes)

explorer = TopExp_Explorer(shapes, TopAbs_EDGE)

lst = []
while explorer.More():
    s = explorer.Current()
    first = topexp_FirstVertex(s)
    last = topexp_LastVertex(s)
    fpnt = BRep_Tool().Pnt(first)
    lpnt = BRep_Tool().Pnt(last)
    print(s, first, fpnt.X(), fpnt.Y(), fpnt.Z())
    if fpnt.Z() != 60 and lpnt.Z() != 60:
        lst.append(s)
    explorer.Next()

# wire = make_wire(lst)

display, start_display, add_menu, add_function_to_menu = init_display()

display.DisplayShape(lst)
display.FitAll()

start_display()
